package com.mt.config;

import cn.hutool.core.lang.Singleton;
import com.mt.pojo.Film;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Wang
 * @Description 电影缓存获取
 * @date 2020/11/25-20:10
 */

//单例模式
public class FilmCacheManager {
    private volatile static Map<String, List<Film>>  filmMap;

    public Map<String, List<Film>> getFilmMap() {
        return filmMap;
    }

    public void setFilmMap(Map<String, List<Film>> filmMap) {
        FilmCacheManager.filmMap = filmMap;
    }

    private FilmCacheManager(){}
    public static Map<String, List<Film>> getInstance() {
        if (filmMap == null) {
            synchronized (Singleton.class) {
                if (filmMap == null) {
                    filmMap=new HashMap<>();
                }
            }
        }
        return filmMap;
    }
}
